this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.Ui=this.BX.Landing.Ui||{};(function(e,t,i,n,s,a,r,o){"use strict";var c=function(e){babelHelpers.inherits(t,e);function t(e){var i;babelHelpers.classCallCheck(this,t);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));i.setEventNamespace("BX.Landing.UI.Field.ProductField");i.subscribeFromOptions(o.fetchEventsFromOptions(e));i.setLayoutClass("landing-ui-field-product");i.onBasketChange=i.onBasketChange.bind(babelHelpers.assertThisInitialized(i));a.Dom.append(i.getProductSelector().wrapper,i.input);i.setProducts(i.options.items);var n=s.PageObject.getRootWindow();n.BX.Event.EventEmitter.subscribe(i.getProductSelector(),"ProductForm:onBasketChange",i.onBasketChange);return i}babelHelpers.createClass(t,[{key:"setProducts",value:function e(t){this.cache.set("products",a.Runtime.clone(t))}},{key:"getProducts",value:function e(){return this.cache.get("products")||[]}},{key:"onBasketChange",value:function e(t){var i=t.getData();this.setProducts(i.basket);this.emit("onChange",{skipPrepare:true})}},{key:"getValue",value:function e(){return this.getProducts().reduce(function(e,t){if(!a.Type.isNil(t.offerId)||!a.Type.isNil(t.fields.productId)){var i=[];if(t.image&&t.image.path){i.push(t.image.path)}else if(t.image&&t.image.preview){var n=document.createElement("div");n.innerHTML=t.image.preview;n=n.querySelector("img");if(n&&n.src){i.push(n.src)}}var s=t.offerId||t.fields.productId;if(e.some(function(e){return e.value===s})){return e}e.push({label:t.fields.name,changeablePrice:false,discount:t.fields.discount,pics:i,price:t.fields.price,quantity:[],selected:false,value:s})}return e},[])}},{key:"getProductSelector",value:function e(){var t=this;return this.cache.remember("productSelector",function(){var e=s.PageObject.getRootWindow();return new e.BX.Catalog.ProductForm({iblockId:t.options.iblockId,showResults:false,allowedDiscountTypes:[n.DiscountType.MONETARY],buttonsPosition:"BOTTOM",newItemPosition:"BOTTOM",basket:t.options.items})})}}]);return t}(t.BaseField);e.ProductField=c})(this.BX.Landing.Ui.Field=this.BX.Landing.Ui.Field||{},BX.Landing.UI.Field,BX.Catalog,BX.Catalog,BX.Landing,BX,BX.Event,BX.Landing.UI.Component);
//# sourceMappingURL=productfield.bundle.map.js